I used following code for setting filter
bool setFilter (Module m, string filtStr) {
string code = "Module m = addr_ " ((addr_ m) int) "\ncurrent=m\nFilter f = " filtStr"\n; set f"
noError(); eval_ code; return (null lastError)
}
SystemAdmin - Tue Mar 01 09:08:00 EST 2011 |
Re: Setting Filter issues
The below seems to do the trick. Thanks for pointing this out. Regards, Mathias
bool setFilter (Module m, string filtStr) {
string code = "
Module m = addr_ " ((addr_ m) int) "
current=m
Filter f = " filtStr"
string check = stringOf (m,f); if (null check) { return_ \"error\"; halt }
set f;return_ \"\""
noError(); string msg = eval_ code; return (null lastError msg)
}
string sErr = "attribute \"abcde\" == \"kljlkj\""
print "Error Case: " setFilter (current, sErr) "\n"
string sOk = "attribute \"Object Text\" == \"kljlkj\""
print "OK case: " setFilter (current, sOk) "\n"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Setting Filter issues Mathias Mamsch - Tue Mar 01 10:57:09 EST 2011
The below seems to do the trick. Thanks for pointing this out. Regards, Mathias
bool setFilter (Module m, string filtStr) {
string code = "
Module m = addr_ " ((addr_ m) int) "
current=m
Filter f = " filtStr"
string check = stringOf (m,f); if (null check) { return_ \"error\"; halt }
set f;return_ \"\""
noError(); string msg = eval_ code; return (null lastError msg)
}
string sErr = "attribute \"abcde\" == \"kljlkj\""
print "Error Case: " setFilter (current, sErr) "\n"
string sOk = "attribute \"Object Text\" == \"kljlkj\""
print "OK case: " setFilter (current, sOk) "\n"
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Thanks, Hardik Shah |
Re: Setting Filter issues SystemAdmin - Tue Mar 01 23:49:02 EST 2011
If you are working on DOORS 9.2-1+ I guess you could be able to check for all the attributes, but on smaller DOORS versions I did not find a possibility to surpress the error. So you would need to parse the string in setFilter before actually applying it to a filter. Something like this:
Regexp greFilterAttribute = regexp "attribute \"([^\"]+)\""
bool setFilter (Module m, string filtStr) {
bool allExist = true
// parse the filter string
Buffer b = create(); b = filtStr
int pos = 0;
while (search(greFilterAttribute, b, pos)) {
string aName = b[pos+start 1:pos+end 1]
print "Checking Attribute:" aName "\n"
int x = end 0
pos += end 0
AttrDef ad = find (m, aName)
if (null ad || !ad.object) { allExist = false; break }
}
delete b
if (!allExist) return false
string code = "
Module m = addr_ " ((addr_ m) int) "
current=m
Filter f = " filtStr"
string check = stringOf (m,f); if (null check) { return_ \"error\"; halt }
set f;return_ \"\""
noError(); string msg = eval_ code; return (null lastError msg)
}
print "Error Filter:\n"
{
string sErr = "attribute \"abcde\" == \"kljlkj\" && attribute \"Object Text\" == \"Hallo\""
print "Error Case: " setFilter (current, sErr) "\n"
}
print "Ok Filter:\n"
{
string sErr = "attribute \"Object Heading\" == \"kljlkj\" && attribute \"Object Text\" == \"Hallo\""
print "OK Case: " setFilter (current, sErr) "\n"
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Setting Filter issues Mathias Mamsch - Wed Mar 02 04:34:58 EST 2011
If you are working on DOORS 9.2-1+ I guess you could be able to check for all the attributes, but on smaller DOORS versions I did not find a possibility to surpress the error. So you would need to parse the string in setFilter before actually applying it to a filter. Something like this:
Regexp greFilterAttribute = regexp "attribute \"([^\"]+)\""
bool setFilter (Module m, string filtStr) {
bool allExist = true
// parse the filter string
Buffer b = create(); b = filtStr
int pos = 0;
while (search(greFilterAttribute, b, pos)) {
string aName = b[pos+start 1:pos+end 1]
print "Checking Attribute:" aName "\n"
int x = end 0
pos += end 0
AttrDef ad = find (m, aName)
if (null ad || !ad.object) { allExist = false; break }
}
delete b
if (!allExist) return false
string code = "
Module m = addr_ " ((addr_ m) int) "
current=m
Filter f = " filtStr"
string check = stringOf (m,f); if (null check) { return_ \"error\"; halt }
set f;return_ \"\""
noError(); string msg = eval_ code; return (null lastError msg)
}
print "Error Filter:\n"
{
string sErr = "attribute \"abcde\" == \"kljlkj\" && attribute \"Object Text\" == \"Hallo\""
print "Error Case: " setFilter (current, sErr) "\n"
}
print "Ok Filter:\n"
{
string sErr = "attribute \"Object Heading\" == \"kljlkj\" && attribute \"Object Text\" == \"Hallo\""
print "OK Case: " setFilter (current, sErr) "\n"
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
It works as expected. but just one minor favor, that is it will fail if the passed attribute value is not valid means if I had enumeration type and then I passed wrong value then it will not work as expected. Thanks, Hardik Shah |
Re: Setting Filter issues SystemAdmin - Wed Mar 02 06:40:54 EST 2011 Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Setting Filter issues Thanks & Regards, Hardik Shah |